package com.js.purs.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.js.purs.domain.PurBindLoadFiles;
import com.js.purs.service.IPurBindLoadFilesService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 招标文件下载Controller
 * 
 * @author lzq
 * @date 20240710
 */
@RestController
@RequestMapping("/loadFiles")
public class PurBindLoadFilesController extends BaseController
{
    @Autowired
    private IPurBindLoadFilesService purBindLoadFilesService;

    /**
     * 查询招标文件下载列表
     */
    @RequiresPermissions("purs:loadFiles:list")
    @GetMapping("/list")
    public TableDataInfo list(PurBindLoadFiles purBindLoadFiles)
    {
        startPage();
        List<PurBindLoadFiles> list = purBindLoadFilesService.selectPurBindLoadFilesList(purBindLoadFiles);
        return getDataTable(list);
    }

    /**
     * 导出招标文件下载列表
     */
    @RequiresPermissions("purs:loadFiles:export")
    @Log(title = "招标文件下载", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurBindLoadFiles purBindLoadFiles)
    {
        List<PurBindLoadFiles> list = purBindLoadFilesService.selectPurBindLoadFilesList(purBindLoadFiles);
        ExcelUtil<PurBindLoadFiles> util = new ExcelUtil<PurBindLoadFiles>(PurBindLoadFiles.class);
        util.exportExcel(response, list, "招标文件下载数据");
    }

    /**
     * 获取招标文件下载详细信息
     */
    @RequiresPermissions("purs:loadFiles:query")
    @GetMapping(value = "/{loadId}")
    public AjaxResult getInfo(@PathVariable("loadId") Long loadId)
    {
        return success(purBindLoadFilesService.selectPurBindLoadFilesByLoadId(loadId));
    }

    /**
     * 新增招标文件下载
     */

    @PostMapping("/insertLoadFile")
    public AjaxResult add(@RequestBody PurBindLoadFiles purBindLoadFiles)
    {
        return toAjax(purBindLoadFilesService.insertPurBindLoadFiles(purBindLoadFiles));
    }

    /**
     * 修改招标文件下载
     */
    @RequiresPermissions("purs:loadFiles:edit")
    @Log(title = "招标文件下载", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurBindLoadFiles purBindLoadFiles)
    {
        return toAjax(purBindLoadFilesService.updatePurBindLoadFiles(purBindLoadFiles));
    }

    /**
     * 删除招标文件下载
     */
    @RequiresPermissions("purs:loadFiles:remove")
    @Log(title = "招标文件下载", businessType = BusinessType.DELETE)
	@DeleteMapping("/{loadIds}")
    public AjaxResult remove(@PathVariable Long[] loadIds)
    {
        return toAjax(purBindLoadFilesService.deletePurBindLoadFilesByLoadIds(loadIds));
    }
}
